<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ page contentType="text/html; charset=UTF-8" language="java"%>
 	<div id="navbar" class="navbar navbar-default height-bar">
 
		<div class="navbar-container" id="navbar-container" style="padding-right: 0px;position: relative;height:100%">
			<div class="navbar-header pull-left" style="width: 40%;position: absolute;top: 0;bottom: 0;margin: auto;height: 30px;cursor:pointer;"">
 				<%-- <img alt="${SYS_LOGO_NAME}" src='<c:choose>
					<c:when test="${logoUrl!=null}">${baseURL}/attach/action/attach/downloadFile.do?id=${logoUrl}</c:when>
					<c:otherwise>${baseURL}/images/index/blue_logo.png</c:otherwise>
				</c:choose>'
				 height="24px" onerror="noImages()" id="logo"> --%>
				 <c:choose>
				 	<c:when test="${empty logoUrl and empty SYS_LOGO_NAME}">
				 		<img  style="width: 18%;margin-top: 5px;" src='${baseURL}/images/index/blue_logo.png?v=math.random()'  height="24px" onerror="noImages()" id="logo" />
				 	</c:when>
				 	
				 	<c:when test="${!empty SYS_LOGO_IMG}">
				 		<img  style="width: 18%;margin-top: 5px;" src='${baseURL}/attach/action/attach/downloadFile.do?id=${SYS_LOGO_IMG}&v=math.random()' height="24px" onerror="noImages()" id="logo" />
				 	</c:when>
				 	 
				 	<c:otherwise >
				 		<div style="font-size:20px;color: #0072cc;line-height:31px">${SYS_LOGO_NAME}</div>
 				 	</c:otherwise>
				</c:choose> 	
				<%--  <div style="font-size: 20px;margin-top: 10px;">${SYS_LOGO_NAME}</div> --%>
			</div>
			<div class="navbar-buttons navbar-header pull-right" role="navigation">
				<ul class="nav ace-nav">
					<c:forEach var="o" items="${menusBean}" varStatus="idx">
				        <c:if test="${idx.index < LEVEL_1_MENU_NUM && o.isAccountMenu != '1' && o.code != 'GRZX'}">
							<li name="${o.id}" data-url="${o.url}" class="light-blue menus_button menus_list">
								<a href="#" class="menu">
									<i class="ace-icon fa fa-star ${o.smallIconPath} blue_icon" title="${o.name}"></i>
									<span>${o.name}</span>
								</a>
				            </li>
				        </c:if>
						<%--
							上面的c:if的判断条件中，如果出现了不符合的菜单，就不在顶部显示，
							会导致实际显示的菜单与设定的菜单不符合。如设定显示5个，但按照上
							面c:if的判断条件，个人中心 这个菜单是不显示的，那么实际显示的只
							有4个。这种情况下把显示菜单的个数(LEVEL_1_MENU_NUM) + 1，以显
							示正确的菜单个数。
						--%>
						<c:if test="${idx.index < LEVEL_1_MENU_NUM && (o.isAccountMenu == '1' || o.code == 'GRZX')}">
							<c:set var="LEVEL_1_MENU_NUM" value="${LEVEL_1_MENU_NUM + 1}"></c:set>
						</c:if>
					</c:forEach>
					<!-- #section:basics/navbar.user_menu -->
					<li class="light-blue" style="margin-right: 10px;">
						<a data-toggle="dropdown" href="#" class="dropdown-toggle" id="user_setting">
 							<img class="nav-user-photo" src='<c:choose><c:when test="${not empty userIconUrl}">${baseURL}/attach/action/attach/downloadFile.do?id=${userIconUrl}
							</c:when><c:otherwise>${baseURL}/default.jpg</c:otherwise></c:choose>' onerror="noImages()" />
							<span class="user-info">
								<small>欢迎您，</small>
								${currentUserName}
							</span>
							<i class="ace-icon fa fa-caret-down"></i>
						</a>
						<c:choose>
							<c:when test="${menusCount<=10}">
								<ul class="user-menu dropdown-menu-right dropdown-menu dropdown-yellow dropdown-caret dropdown-close">
									<c:forEach var="o" items="${menusBean}" varStatus="idx">
										<c:if test="${idx.count<=LEVEL_1_MENU_NUM && o.isAccountMenu != '1' && o.code != 'GRZX' }">
										<li class="menus_hidden">
											<a data-name="${o.name}" class="menus_item menus_button" name="${o.id}" alt="${o.code}" style="margin:10px 0px;">
												<i class="ace-icon fa fa-star ${o.smallIconPath} blue_icon" title="${o.name}"></i>
												<span style="margin-left:8px">${o.name}</span>
											</a>
										</li>
										</c:if>
										<c:if test="${idx.count>LEVEL_1_MENU_NUM && o.isAccountMenu != '1' && o.code != 'GRZX'}">
										<li>
											<a data-name="${o.name}" class="menus_item menus_button" name="${o.id}" alt="${o.code}" style="margin:10px 0px">
												<i class="ace-icon fa fa-star ${o.smallIconPath} blue_icon" title="${o.name}"></i>
	 											<span style="margin-left:8px">${o.name}</span>
											</a>
										</li>
										</c:if>
						        	</c:forEach>
						        	<!-- <li class="divider"></li> -->
						        	<!-- 显示账号菜单	start -->
						        	<c:forEach var="o" items="${menusBean}" varStatus="idx">
						        		<c:if test="${o.isAccountMenu == '1' }">
							        		<c:choose>
								        		<c:when test="${fn:length(o.childrens) > 0 }">
									        		<li name="${o.id}" data-url="${o.url}" class="light-blue menus_button menus_list">
														<a href="#" class="menu ${o.menuClass }">
															<i class="ace-icon fa fa-star ${o.smallIconPath} blue_icon" title="${o.name}"></i>
															<span>${o.name}</span>
														</a>
										            </li>
								        		</c:when>
								        		<c:otherwise>
									        		<li>
														<a href="#" class="${o.menuClass }">
															<i class="${o.smallIconPath}"></i>
															${o.name }
														</a>
													</li>
								        		</c:otherwise>
							        		</c:choose>
							        	</c:if>
						        	</c:forEach>
						        	<!-- 显示账号菜单	end -->
						        	<!-- <li>
										<a href="#" class="index">
											<i class="ace-icon fa fa-cog"></i>
											配置首页
										</a>
									</li> -->
						        	 <!--  <li>
										<a href="#" class="index">
											<i class="ace-icon fa fa-cog"></i>
											配置首页
										</a>
									</li> -->
									<li>
											<a data-name="${GRZX.name}" class="menus_item menus_button" name="${GRZX.id}" alt="${GRZX.code}" style="margin:10px 0px">
												<i class="ace-icon fa fa-star ${GRZX.smallIconPath} blue_icon" title="${GRZX.name}"></i>
	 											<span style="margin-left:8px">${GRZX.name}</span>
											</a>
									</li>
						        	<li>
										<a href="#" class="password">
											<i class="ace-icon fa fa-user"></i>
											<span style="margin-left:8px">修改密码</span>
										</a>
									</li>
									<li>
										<a href="#" class="logout">
											<i class="ace-icon fa fa-power-off org_icon"></i>
											<span style="margin-left:8px">注销</span>
										</a>
									</li>  
						        </ul>	
							</c:when>
							
							<c:otherwise>
								<ul class="user-menu dropdown-menu-right dropdown-menu dropdown-yellow dropdown-caret dropdown-close">
									<c:forEach var="o" items="${menusBean}" varStatus="idx">
										<c:if test="${idx.count<=LEVEL_1_MENU_NUM&&idx.count%2==0}">
										<li style="float: right;height:30px;" class=" menus_hidden">
											<a data-name="${o.name}" class="menus_item menus_button" name="${o.id}" alt="${o.code}">
												<i class="ace-icon fa fa-star ${o.smallIconPath} blue_icon" title="${o.name}"></i>
	 											<span style="margin-left:8px">${o.name}</span>
											</a>
										</li>
										</c:if>
										<c:if test="${idx.count<=LEVEL_1_MENU_NUM&&idx.count%2!=0}">
										<li style="float: left;height:30px;" class=" menus_hidden">
											<a data-name="${o.name}" class="menus_item menus_button" name="${o.id}" alt="${o.code}">
												<i class="ace-icon fa fa-star ${o.smallIconPath} blue_icon" title="${o.name}"></i>
	 											<span style="margin-left:8px">${o.name}</span>
											</a>
										</li>
										</c:if>
										<c:if test="${idx.count>LEVEL_1_MENU_NUM&&idx.count%2==0}">
										<li style="float: right;height:30px;">
											<a data-name="${o.name}" class="menus_item menus_button" name="${o.id}" alt="${o.code}">
												<i class="ace-icon fa fa-star ${o.smallIconPath} blue_icon" title="${o.name}"></i>
	 											<span style="margin-left:8px">${o.name}</span>
											</a>
										</li>
										</c:if>
										<c:if test="${idx.count>LEVEL_1_MENU_NUM&&idx.count%2!=0}">
										<li style="float: left;height:30px;">
											<a data-name="${o.name}" class="menus_item menus_button" name="${o.id}" alt="${o.code}">
												<i class="ace-icon fa fa-star ${o.smallIconPath} blue_icon" title="${o.name}"></i>
												<span style="margin-left:8px">${o.name}</span>
											</a>
										</li>
										</c:if>
						        	</c:forEach>
						        	<div style="clear:both;"></div>
						        	<li class="divider" style="width:300px"></li>
									<li>
										<a data-name="${GRZX.name}" class="menus_item menus_button" name="${GRZX.id}" alt="${GRZX.code}" style="margin:10px 0px">
											<i class="ace-icon fa fa-star ${GRZX.smallIconPath} blue_icon" title="${GRZX.name}"></i>
											<span style="margin-left:8px">${GRZX.name}</span>
										</a>
									</li>
						        	<li>
										<a href="#" class="password">
											<i class="ace-icon fa fa-user"></i>
											<span style="margin-left:8px">修改密码</span>
										</a>
									</li>
									<li>
										<a href="#" class="logout">
											<i class="ace-icon fa fa-power-off org_icon"></i>
											<span style="margin-left:8px">注销</span>
										</a>
									</li>
						        </ul>
							</c:otherwise>
						</c:choose>
 					</li>
 					
 					<!-- #section:basics/navbar.user_menu -->
					<li class="light-blue" id="accountMenu" style="display: none;">
						<a data-toggle="dropdown" href="#" class="dropdown-toggle" id="user_setting">
							<span class="user-info">
								<small>当前帐套</small>
								<p id="currentAccount"></p>
							</span>
							<i class="ace-icon fa fa-caret-down"></i>
						</a>
						<ul class="user-menu dropdown-menu-right dropdown-menu dropdown-yellow dropdown-caret dropdown-close" id="accountList">
				        </ul>	
 					</li>
				</ul>
			</div>
		</div>
	</div>
	
 		
	<script type="text/javascript">	
	$(function() {
		$(".pull-left").click(function(){
			location.reload(true);
		});
		
		
		
		$(".navbar-brand").click(function(){
			tab.selectTabItem("home");
		});
		
		//退出注销当前用户
		$(".logout").click(function() {
			$.ligerDialog.confirm('亲，请问您真的要离开么?', function (yes)
			{
				if(yes){
					window.location.href = "${baseURL}/system/security/logout/logout.do";
				}
			});
			return false;
		});
		
		//弹出修改密码弹出框
		$(".password").click(function() {
			f_addTab('updatePassword', '修改密码','${baseURL}/updatePassword.jsp');
			return false;
		});

 		$(".index").click(function() {
			//f_addTab('index', '配置首页','${baseURL}/panel/layout/layoutlist/listIndex.do');
			window.frames["indexFrame"].changePanel();
			return false;
		}); 
		
		$(".ace-nav").children("li").click(function(e){
			var name = $(this).attr("name")
			if (name == undefined) {
				return false;
			}
			e.stopPropagation(); 
			//调用content.jsp中方法
		    changeTab($(this), name)
			return false; 	
 		});
		$(".user-menu").children("li").click(function(e){
			var name = $(this).find('a').attr("name")
			if (name == undefined) {
				return false;
			}
			e.stopPropagation(); 
			//调用content.jsp中方法
		    changeTab($(this), name)
			return false;
 		});
		
		<c:choose>
		<c:when test="${!empty SYS_BANNER_IMG}">
		$(".navbar").css("background","url(${baseURL}/attach/action/attach/downloadFile.do?id=${SYS_BANNER_IMG})")
		</c:when>
		<c:when test="${!empty SYS_BANNER_COLOR}">
		$(".navbar").css("background","${SYS_BANNER_COLOR}")
		</c:when>
		</c:choose>
		
		<c:if test="${!empty SYS_MENU_COLOR}">
		$(".pull-right").css("background","${SYS_MENU_COLOR}")
		</c:if>
		
	});
	
	function FF_Change(id){
        jQuery.ligerDialog.confirm('您确定切换该帐套吗?', function (confirm) {
        	$.ajax({
    			type: "GET",
    			url: "${baseURL}/account/account/accountsave/changeAccount.do",
    			dataType : "json",
    			data: {id:id},
    			beforeSend: function (){
    	             LG.loading = true;
    	             LG.showLoading('正在处理中...请稍候');
    	        },
    	        complete: function (){
    	             LG.loading = false;	  
    	             LG.hideLoading();
    	        },
    			success: function(msg){
    				if(msg && msg.hasOk){
    					 window.location.reload();
    				}else{
    					LG.showError("操作失败!失败信息如下:<br/>"+msg.message+"<br/>如您对以上信息有疑问，请联系管理人员!");
    				}
    			}
    		});
       	});
	}
	
	function noImages(){
		
	}
	
	
	</script>